//
//  SkillInfoView.m
//  BasketballClub
//
//  Created by 孙鸿吉 on 16/1/9.
//  Copyright © 2016年 孙鸿吉. All rights reserved.
//

#import "SkillInfoView.h"
typedef NS_ENUM(NSInteger,ClickType){
    clicktypeNone,
    clicktypeUser,
    clicktypePass
};
@interface SkillInfoView()<UITextFieldDelegate>
//猫的手
@property (strong,nonatomic) UIImageView *lefthand;
@property (strong,nonatomic) UIImageView *righthand;


//猫的蒙眼胳膊
@property (strong,nonatomic) UIImageView *lefthArm;
@property (strong,nonatomic) UIImageView *rightArm;
@property (assign,nonatomic) ClickType clicktype;
@end
@implementation SkillInfoView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self allViews];
    }
    return self;
}
- (void)allViews
{
    //导航
    self.navigationView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 64 * LAYOUT_SIZE_HEIGHT)];
    self.navigationView.backgroundColor = ColorHex(0x0d1c38);
    [self addSubview:self.navigationView];
    //标题
    self.navigationLabal = [[UILabel alloc]initWithFrame:CGRectMake(SCREEN_WIDTH/2 - (25 * LAYOUT_SIZE), 29 * LAYOUT_SIZE_HEIGHT, 50* LAYOUT_SIZE, 26 * LAYOUT_SIZE_HEIGHT)];
    self.navigationLabal.text = @"详情";
    self.navigationLabal.textAlignment = 1;
    self.navigationLabal.textColor = [UIColor yellowColor];
    self.navigationLabal.font = [UIFont systemFontOfSize:17 * LAYOUT_SIZE];
    [self.navigationView addSubview:self.navigationLabal];
    //左边按钮
    self.leftButton = [[UIButton alloc]initWithFrame:CGRectMake(10 * LAYOUT_SIZE, 29 * LAYOUT_SIZE_HEIGHT, 50 * LAYOUT_SIZE, 26 * LAYOUT_SIZE_HEIGHT)];
    [self.leftButton setImage:[UIImage imageNamed:@"fanhui@2x"] forState:UIControlStateNormal];
    [self.navigationView addSubview:self.leftButton];
    //右边按钮
    self.rightButton = [[UIButton alloc]initWithFrame:CGRectMake(SCREEN_WIDTH - (60 * LAYOUT_SIZE), 29 * LAYOUT_SIZE_HEIGHT, 50 * LAYOUT_SIZE, 26 * LAYOUT_SIZE_HEIGHT)];
    [self.rightButton setImage:[UIImage imageNamed:@"soucangle1@2x"] forState:UIControlStateNormal];
    [self.navigationView addSubview:self.rightButton];
    
    //网页
    self.webView = [[UIWebView alloc]initWithFrame:CGRectMake(0, 64 * LAYOUT_SIZE_HEIGHT, SCREEN_WIDTH, SCREEN_HEIGHT - (108 * LAYOUT_SIZE_HEIGHT))];
    [self addSubview:self.webView];
    //tabbar
    self.toolView = [[UIView alloc]initWithFrame:CGRectMake(0, SCREEN_HEIGHT - (44 * LAYOUT_SIZE_HEIGHT), SCREEN_WIDTH, 44 * LAYOUT_SIZE_HEIGHT)];
    self.toolView.backgroundColor = ColorHex(0x0d1c38);
    [self addSubview:self.toolView];
    //喜欢
    self.likeButton = [[UIButton alloc]initWithFrame:CGRectMake(90 * LAYOUT_SIZE, 7 * LAYOUT_SIZE_HEIGHT, 30 * LAYOUT_SIZE, 30 * LAYOUT_SIZE_HEIGHT)];
    [self.likeButton setBackgroundImage:[UIImage imageNamed:@"xihuan1@2x"] forState:UIControlStateNormal];
    [self.toolView addSubview:self.likeButton];
    
    self.likeCount = [[UILabel alloc]initWithFrame:CGRectMake(122 * LAYOUT_SIZE, 7 * LAYOUT_SIZE_HEIGHT, 30 * LAYOUT_SIZE, 30 * LAYOUT_SIZE_HEIGHT)];
    self.likeCount.backgroundColor = [UIColor clearColor];
//    self.likeCount.text = @"1";
    self.likeCount.textColor = [UIColor yellowColor];
    [self.toolView addSubview:self.likeCount];
    //评论
    self.talkButton = [[UIButton alloc]initWithFrame:CGRectMake(195 * LAYOUT_SIZE, 7 * LAYOUT_SIZE_HEIGHT, 30 * LAYOUT_SIZE, 30 * LAYOUT_SIZE_HEIGHT)];
    [self.talkButton setBackgroundImage:[UIImage imageNamed:@"pnglun@2x"] forState:UIControlStateNormal];
    [self.toolView addSubview:self.talkButton];
    
    self.talkCount = [[UILabel alloc]initWithFrame:CGRectMake(227 * LAYOUT_SIZE, 7 * LAYOUT_SIZE_HEIGHT, 30 * LAYOUT_SIZE, 30 * LAYOUT_SIZE_HEIGHT)];
//    self.talkCount.text = @"1";
    self.talkCount.textColor = [UIColor yellowColor];
    self.talkCount.backgroundColor = [UIColor clearColor];
    [self.toolView addSubview:self.talkCount];
    //转发
    self.shareButton = [[UIButton alloc]initWithFrame:CGRectMake(300 * LAYOUT_SIZE, 7 * LAYOUT_SIZE_HEIGHT, 30 * LAYOUT_SIZE, 30 * LAYOUT_SIZE_HEIGHT)];
    [self.shareButton setBackgroundImage:[UIImage imageNamed:@"zhuanfa@2x"] forState:UIControlStateNormal];
    [self.toolView addSubview:self.shareButton];
    [self pushLgoinView];
}
- (void)pushLgoinView
{
    self.backgroundView = [[UIView alloc]initWithFrame:CGRectMake(SCREEN_WIDTH/2 - (160 * LAYOUT_SIZE), SCREEN_HEIGHT, 320 * LAYOUT_SIZE, 350 * LAYOUT_SIZE_HEIGHT)];
    self.backgroundView.backgroundColor = [UIColor clearColor];
    [self addSubview:self.backgroundView];

    UIImageView *head = [[UIImageView alloc]initWithFrame:CGRectMake(85 * LAYOUT_SIZE, 27 * LAYOUT_SIZE_HEIGHT, 150 * LAYOUT_SIZE, 80 * LAYOUT_SIZE_HEIGHT)];
    head.image = [UIImage imageNamed:@"header"];
    [self.backgroundView addSubview:head];
    
    _lefthArm = [[UIImageView alloc]initWithFrame:CGRectMake(75 * LAYOUT_SIZE, 100 * LAYOUT_SIZE_HEIGHT, 40 * LAYOUT_SIZE, 65 * LAYOUT_SIZE_HEIGHT)];
    _lefthArm.image = [UIImage imageNamed:@"left"];
    [self.backgroundView addSubview:_lefthArm];
    
    _rightArm = [[UIImageView alloc]initWithFrame:CGRectMake(215 * LAYOUT_SIZE, 100 * LAYOUT_SIZE_HEIGHT, 40 * LAYOUT_SIZE, 65 * LAYOUT_SIZE_HEIGHT)];
    _rightArm.image = [UIImage imageNamed:@"right"];
    [self.backgroundView addSubview:_rightArm];
    
    self.loginPresentView = [[UIView alloc]initWithFrame:CGRectMake(0, 100 * LAYOUT_SIZE_HEIGHT, 320 * LAYOUT_SIZE, 250 * LAYOUT_SIZE_HEIGHT)];
    self.loginPresentView.backgroundColor = ColorHex(0x0d1c38);
    self.loginPresentView.layer.cornerRadius = 8;
    self.loginPresentView.layer.masksToBounds = YES;
    [self.backgroundView addSubview:self.loginPresentView];
    
    _lefthand = [[UIImageView alloc]initWithFrame:CGRectMake(75 * LAYOUT_SIZE, 83 * LAYOUT_SIZE_HEIGHT, 35 * LAYOUT_SIZE, 30 * LAYOUT_SIZE_HEIGHT)];
    _lefthand.image = [UIImage imageNamed:@"hand"];
    [self.backgroundView addSubview:_lefthand];
    
    _righthand = [[UIImageView alloc]initWithFrame:CGRectMake(210 * LAYOUT_SIZE, 83 * LAYOUT_SIZE_HEIGHT, 35 * LAYOUT_SIZE, 30 * LAYOUT_SIZE_HEIGHT)];
    _righthand.image = [UIImage imageNamed:@"hand"];
    [self.backgroundView addSubview:_righthand];
    
    
    self.loginPresentImageView = [[UIImageView alloc]initWithFrame:CGRectMake(50 * LAYOUT_SIZE, 10 * LAYOUT_SIZE_HEIGHT, 220 * LAYOUT_SIZE, 25 * LAYOUT_SIZE_HEIGHT)];
    self.loginPresentImageView.image = [UIImage imageNamed:@"logo1"];
    [self.loginPresentView addSubview:self.loginPresentImageView];
    
    self.userImageView = [[UIImageView alloc]initWithFrame:CGRectMake(20 * LAYOUT_SIZE, 65 * LAYOUT_SIZE_HEIGHT, 30 * LAYOUT_SIZE, 30 * LAYOUT_SIZE_HEIGHT)];
    self.userImageView.image = [UIImage imageNamed:@"phoneNumberBackGround@2x"];
    [self.loginPresentView addSubview:self.userImageView];
    
    self.peopleImageView = [[UIImageView alloc]initWithFrame:CGRectMake(25 * LAYOUT_SIZE, 70 * LAYOUT_SIZE_HEIGHT, 20 * LAYOUT_SIZE, 20 * LAYOUT_SIZE_HEIGHT)];
    self.peopleImageView.image = [UIImage imageNamed:@"iconfont-ren1"];
//    self.peopleImageView.center = self.userImageView.center;
    [self.loginPresentView addSubview:self.peopleImageView];
    
    self.userBackImageView = [[UIImageView alloc]initWithFrame:CGRectMake(55 * LAYOUT_SIZE, 65 * LAYOUT_SIZE_HEIGHT, 245 * LAYOUT_SIZE, 30 * LAYOUT_SIZE_HEIGHT)];
    self.userBackImageView.image = [UIImage imageNamed:@"phoneNumberBackGroundInput@2x"];
    [self.loginPresentView addSubview:self.userBackImageView];
    
    self.usernameTF = [[UITextField alloc]initWithFrame:CGRectMake(60 * LAYOUT_SIZE, 65 * LAYOUT_SIZE_HEIGHT, 230 * LAYOUT_SIZE , 30 * LAYOUT_SIZE_HEIGHT)];
    self.usernameTF.placeholder = @"账号";
    self.usernameTF.delegate = self;
    self.usernameTF.clearButtonMode = UITextFieldViewModeAlways;
    [self.usernameTF setValue:[UIFont boldSystemFontOfSize:16 * LAYOUT_SIZE] forKeyPath:@"_placeholderLabel.font"];
    [self.usernameTF setValue:ColorHexA(0xFFFFE0, 0.7) forKeyPath:@"_placeholderLabel.textColor"];
    [self.loginPresentView addSubview:self.usernameTF];
    
    
    self.passImageView = [[UIImageView alloc]initWithFrame:CGRectMake(20 * LAYOUT_SIZE, 105 * LAYOUT_SIZE_HEIGHT, 30 * LAYOUT_SIZE, 30 * LAYOUT_SIZE_HEIGHT)];
    self.passImageView.image = [UIImage imageNamed:@"phoneNumberBackGround@2x"];
    [self.loginPresentView addSubview:self.passImageView];
    
    self.keyImageView = [[UIImageView alloc]initWithFrame:CGRectMake(25 * LAYOUT_SIZE, 110 * LAYOUT_SIZE_HEIGHT, 20 * LAYOUT_SIZE, 20 * LAYOUT_SIZE_HEIGHT)];
    self.keyImageView.image = [UIImage imageNamed:@"iconfont-michi"];
//    self.keyImageView.center = self.passImageView.center;
    [self.loginPresentView addSubview:self.keyImageView];
    
    self.passBackImageView = [[UIImageView alloc]initWithFrame:CGRectMake(55 * LAYOUT_SIZE, 105 * LAYOUT_SIZE_HEIGHT, 245 * LAYOUT_SIZE, 30 * LAYOUT_SIZE_HEIGHT)];
    self.passBackImageView.image = [UIImage imageNamed:@"phoneNumberBackGroundInput@2x"];
    [self.loginPresentView addSubview:self.passBackImageView];
    
    self.passwordTF = [[UITextField alloc]initWithFrame:CGRectMake(60 * LAYOUT_SIZE, 105 * LAYOUT_SIZE_HEIGHT, 230 * LAYOUT_SIZE, 30 * LAYOUT_SIZE_HEIGHT)];
    self.passwordTF.placeholder = @"密码";
    self.passwordTF.delegate = self;
    [self.passwordTF setValue:[UIFont systemFontOfSize:16 * LAYOUT_SIZE] forKeyPath:@"_placeholderLabel.font"];
    self.passwordTF.secureTextEntry = YES;
    self.passwordTF.clearButtonMode = UITextFieldViewModeAlways;
    [self.passwordTF setValue:ColorHexA(0xFFFFE0, 0.7) forKeyPath:@"_placeholderLabel.textColor"];
    [self.loginPresentView addSubview:self.passwordTF];
    
    self.findPWDButton = [[UIButton alloc]initWithFrame:CGRectMake(230 * LAYOUT_SIZE, 145 * LAYOUT_SIZE_HEIGHT, 50 * LAYOUT_SIZE, 10 * LAYOUT_SIZE_HEIGHT)];
    [self.findPWDButton setTitle:@"忘记密码?" forState:UIControlStateNormal];
    self.findPWDButton.titleLabel.font = [UIFont systemFontOfSize:10 * LAYOUT_SIZE];
    [self.findPWDButton setTitleColor:[UIColor yellowColor] forState:UIControlStateNormal];
    [self.loginPresentView addSubview:self.findPWDButton];
    
    self.registButton = [[UIButton alloc]initWithFrame:CGRectMake(20 * LAYOUT_SIZE, 170 * LAYOUT_SIZE_HEIGHT, 135 * LAYOUT_SIZE, 30 * LAYOUT_SIZE_HEIGHT)];
    [self.registButton setTitle:@"注册" forState:UIControlStateNormal];
    self.registButton.backgroundColor = ColorHex(0x90EE90);
    self.registButton.layer.masksToBounds = YES;
    self.registButton.layer.cornerRadius = 8;
    [self.loginPresentView addSubview:self.registButton];
    
    self.loginButton = [[UIButton alloc]initWithFrame:CGRectMake(165 * LAYOUT_SIZE, 170 * LAYOUT_SIZE_HEIGHT, 135 * LAYOUT_SIZE, 30 * LAYOUT_SIZE_HEIGHT)];
    [self.loginButton setTitle:@"登陆" forState:UIControlStateNormal];
    self.loginButton.backgroundColor = ColorHex(0x90EE90);
    self.loginButton.layer.masksToBounds = YES;
    self.loginButton.layer.cornerRadius = 8;
    [self.loginPresentView addSubview:self.loginButton];
    
    self.messageLabel = [[UILabel alloc]initWithFrame:CGRectMake(210 * LAYOUT_SIZE, 230 * LAYOUT_SIZE_HEIGHT, 110 * LAYOUT_SIZE, 20 * LAYOUT_SIZE_HEIGHT)];
    self.messageLabel.text = @"下滑关闭登陆窗口";
    self.messageLabel.textAlignment = 1;
    self.messageLabel.textColor = [UIColor yellowColor];
    self.messageLabel.font = [UIFont systemFontOfSize:10 * LAYOUT_SIZE];
    [self.loginPresentView addSubview:self.messageLabel];

}

-(void)textFieldDidBeginEditing:(UITextField *)textField{
    if ([textField isEqual:_usernameTF]) {
        if (_clicktype != clicktypePass) {
            _clicktype =clicktypeUser;
            return;
        }
        _clicktype=clicktypeUser;
        
        [UIView animateWithDuration:0.5 animations:^{
            self.lefthArm.frame = CGRectMake(self.lefthArm.frame.origin.x - 45 * LAYOUT_SIZE, self.lefthArm.frame.origin.y + 30 * LAYOUT_SIZE_HEIGHT, self.lefthArm.frame.size.width, self.lefthArm.frame.size.height);
            
            self.rightArm.frame = CGRectMake(self.rightArm.frame.origin.x+48 * LAYOUT_SIZE, self.rightArm.frame.origin.y + 30 * LAYOUT_SIZE_HEIGHT, self.rightArm.frame.size.width, self.rightArm.frame.size.height);
            
            self.lefthand.frame = CGRectMake(self.lefthand.frame.origin.x-70 * LAYOUT_SIZE, self.lefthand.frame.origin.y, 40 * LAYOUT_SIZE, 40 * LAYOUT_SIZE_HEIGHT);
            self.righthand.frame = CGRectMake(self.righthand.frame.origin.x +30 * LAYOUT_SIZE, self.righthand.frame.origin.y, 40 * LAYOUT_SIZE, 40 * LAYOUT_SIZE_HEIGHT);
        } completion:^(BOOL finished) {
            
        }];
    }else if ([textField isEqual:_passwordTF]){
        if (_clicktype == clicktypePass)
        {
            return;
        }
        _clicktype = clicktypePass;
        
        [UIView animateWithDuration:0.5 animations:^{
            self.lefthArm.frame = CGRectMake(self.lefthArm.frame.origin.x + 45 * LAYOUT_SIZE, self.lefthArm.frame.origin.y - 30 * LAYOUT_SIZE_HEIGHT, self.lefthArm.frame.size.width, self.lefthArm.frame.size.height);
            
            self.rightArm.frame = CGRectMake(self.rightArm.frame.origin.x - 48 * LAYOUT_SIZE, self.rightArm.frame.origin.y - 30 * LAYOUT_SIZE_HEIGHT, self.rightArm.frame.size.width, self.rightArm.frame.size.height);
            
            self.lefthand.frame = CGRectMake(self.lefthand.frame.origin.x + 70 * LAYOUT_SIZE, self.lefthand.frame.origin.y, 0, 0);
            self.righthand.frame = CGRectMake(self.righthand.frame.origin.x - 30 * LAYOUT_SIZE, self.righthand.frame.origin.y, 0, 0);
        } completion:^(BOOL finished) {
            
        }];
    }
    
}

@end
